#!/bin/bash

REGISTRY_URL="registry.cn-hangzhou.aliyuncs.com"
NAME_SPACE="ksami"
BUILD_TAG="1.0"

if [ "$1" != "" ];
    then
    BUILD_TAG="$1"
fi

REGISTRY_URL="registry.cn-hangzhou.aliyuncs.com"
docker login --username=tb5545622_88 $REGISTRY_URL --password=
push_tag

push_tag()
{
    set -e
    #build
    cd $WORKSPACE
	  yarn install && npm run build

    docker build -t milk_cup_manager_ui:$BUILD_TAG .
    docker tag milk_cup_manager_ui:$BUILD_TAG $REGISTRY_URL/$NAME_SPACE/milk_cup_manager_ui:$BUILD_TAG
    docker push $REGISTRY_URL/$NAME_SPACE/sora:$BUILD_TAG
    docker rmi milk_cup_manager_ui:$BUILD_TAG
    docker rmi $REGISTRY_URL/$NAME_SPACE/sora:$BUILD_TAG

    rm -rf $WORKSPACE
}


